using System;
using I2.Loc;
using UnityEngine;

[Serializable]
public class MissionTargetBase : MonoBehaviour
{
	public int needCountTarget = 1;

	public int curCountTarget;

	public string startMessageTerm;

	[HideInInspector]
	public TargetParameter curParametr;

	[HideInInspector]
	public MissionBase curMission;

	[SerializeField]
	protected bool agrMobFromStart;

	private string _messageStart = string.Empty;

	public string messageStart
	{
		get
		{
			if (string.IsNullOrEmpty(_messageStart))
			{
				string term = "new_Missions/" + base.transform.parent.name + "_d_" + base.gameObject.name + "_start";
				_messageStart = ScriptLocalization.Get(term);
			}
			return _messageStart;
		}
	}

	public void OnStart()
	{
		if (!startMessageTerm.Equals(string.Empty))
		{
			string text = ScriptLocalization.Get("new_Missions/" + startMessageTerm);
			if (!text.Equals(string.Empty))
			{
				ManagerMissions.instance.hud.missionNote.ShowNoteText(text);
			}
		}
		OnStartTarget();
	}

	protected virtual bool OnStartTarget()
	{
		if (TargetIsComplete())
		{
			CompleteTarget();
			return false;
		}
		if (agrMobFromStart)
		{
			StartAgrMobs();
		}
		curParametr.isStarted = true;
		return true;
	}

	protected void StartAgrMobs()
	{
	}

	public virtual bool ShowTimer()
	{
		return false;
	}

	public virtual void OnStopTarget()
	{
		curParametr.isStarted = false;
	}

	public virtual void OnUpdateTarget()
	{
	}

	protected void CompleteTarget()
	{
		curParametr.SetIsCompletedTarget(true);
		OnStopTarget();
	}

	protected void OnFailedTarget()
	{
	}

	protected virtual void OnShowStartMsg()
	{
	}

	protected virtual bool TargetIsComplete()
	{
		return curCountTarget >= needCountTarget;
	}
}
